package ma.ac.onousc.gestionfi.budget.model.DAO.DAOBean;

import java.util.List;

import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;

import ma.ac.onousc.gestionfi.budget.model.Etablissement;
import ma.ac.onousc.gestionfi.budget.model.ProgrammeEmploi;
import ma.ac.onousc.gestionfi.budget.model.DAO.EtablissementDAO;

@Stateless
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
public class EtablissementDAOBean extends
		GenericEJB3Bean<Etablissement, Integer> implements EtablissementDAO {
	@Override
	public Etablissement findSiege() {
		return (Etablissement) this.getEntityManager()
				.createNamedQuery("Etablissement.findSiege").getResultList()
				.get(0);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Etablissement> findCUs() {
		return this.getEntityManager()
				.createNamedQuery("Etablissement.findCUs").getResultList();
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Etablissement> findNonSoumis(ProgrammeEmploi programmeEmploi) {
		return this.getEntityManager()
				.createNamedQuery("Etablissement.findAllNonSoumis")
				.setParameter("ANNEE", programmeEmploi.getIdProgrammeEmploi())
				.getResultList();
	}
}